package com.woniuxy01;

import java.util.Arrays;

public class Test04 {
    public static void main(String[] args) {
//        int[] a=new int[]{1,2,3,4,5};
//        //数组扩容
//        int[] b=new int[10];
//        for(int i=0;i<a.length;i++){
//            b[i]=a[i];
//        }
//        a=b;
//        System.out.println(Arrays.toString(a));

        int[] a = new int[]{1, 2, 3, 4, 5};
//        original – the array to be copied
//        newLength – the length of the copy to be returned
        a = Arrays.copyOf(a, 10);
        System.out.println(Arrays.toString(a));


        int[] src = new int[]{1, 2, 3, 4, 5};

        int srcPos = 0;
        int[] dest=new int[10];
        int destPos = 0;
        //src – the source array.
        // srcPos – starting position in the source array.
        // dest – the destination array.
        // destPos – starting position in the destination data.
        // length – the number of array elements to be copied.
        System.arraycopy(src, srcPos, dest, destPos, src.length);
        System.out.println(Arrays.toString(dest));
    }
}
